package com.lj.eduservice.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lj.eduservice.entity.Course;
import com.lj.eduservice.entity.Teacher;
import com.lj.eduservice.service.CourseService;
import com.lj.eduservice.service.TeacherService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author luojing
 * @version 1.0
 * @date 2021/6/17 16:16
 */
@RestController
@RequestMapping("/eduservice/indexFront")
public class IndexFrontController {

    @Autowired
    private CourseService courseService;
    @Autowired
    private TeacherService teacherService;

    @GetMapping("hotCourse")
    @ApiOperation("八条热门课程")
    public List<Course> hotCourse() {
        return courseService.list(new QueryWrapper<Course>()
                .orderByDesc("view_count")
                .last("limit 8"));
    }

    @GetMapping("hotTeacher")
    @ApiOperation("四条热门讲师")
    public List<Teacher> hotTeacher() {
        return teacherService.list(new QueryWrapper<Teacher>()
                .orderByDesc("id")
                .last("limit 4"));
    }
}
